# -*- coding: utf-8 -*-
"""
创建日期: 2024/9/18   10:46

@author: justinc
@blog: https://blog.csdn.net/sjc122333?type=blog
@gitee: https://gitee.com/justinc666

"""
from abc import ABCMeta, abstractmethod


class Payment(metaclass=ABCMeta):
    @abstractmethod
    def pay(self, money):
        pass


class Alipay(Payment):
    def __init__(self, huabei=False):
        self.huabei = huabei

    def pay(self, money):
        if self.huabei:
            print(f"花呗支付{money}元。")
        else:
            print(f"支付宝支付{money}元。")


class Wechat(Payment):
    def __init__(self, xyhf=False):
        self.xyhf = xyhf

    def pay(self, money):
        if self.xyhf:
            print(f"先用后付支付{money}元。")
        else:
            print(f"微信支付{money}元。")


class PaymentFactory(metaclass=ABCMeta):
    @abstractmethod
    def create_payment(self):
        pass


class AlipayFactory(PaymentFactory):
    def create_payment(self):
        return Alipay()


class WechatFactory(PaymentFactory):
    def create_payment(self):
        return Wechat()


class huabeiFactory(PaymentFactory):
    def create_payment(self):
        return Alipay(huabei=True)


class xyhfFactory(PaymentFactory):
    def create_payment(self):
        return Wechat(xyhf=True)


pf = xyhfFactory()
p = pf.create_payment()
p.pay(100)
